<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Chat</title>
</head>
<body>

<!-- begin::chat block -->
<div class="row no-gutters chat-block" th:fragment="chat(status)" th:if="(${status} eq 2) or (${status} eq 21)" data-backround-image="https://www.hualigs.cn/image/605b14c7b9090.jpg">

    <!-- begin::chat sidebar -->
    <div class="col-lg-4 chat-sidebar border-right">

        <!-- begin::chat sidebar search -->
        <div class="chat-sidebar-header">
            <div class="d-flex">
                <div class="pr-3">
                    <div class="avatar avatar-sm">
                        <img src="assets/media/image/photo1.jpg" class="rounded-circle"
                             alt="image">
                    </div>
                </div>
                <div>
                    <h6 class="mb-1"><p th:text="(${session.user} != null)?${session.user.realname}:''"></p></h6>
                    <div class="m-0 small text-muted"><p th:text="(${session.user} != null)?${session.user.servicerole}:''"></p></div>
                </div>
                <div class="ml-auto">
                    <div class="dropdown">
                        <a href="#" data-toggle="dropdown">
                            <i class="width-18 height-18" data-toggle="tooltip" title="Settings"
                               data-feather="settings"></i>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right">
                            <a class="dropdown-item" href="#">View Profile</a>
                            <a class="dropdown-item" href="#">Edit Profile</a>
                            <a class="dropdown-item" href="#">Add status</a>
                            <a class="dropdown-item" href="#">Settings</a>
                        </div>

                    </div>

                </div>

            </div>
            <form action="/session/search" shiro:hasPermission="announce">
                <div class="input-group">
                    <input type="text" name="searchname" class="form-control" placeholder="Chat search"
                           aria-describedby="button-addon1">
                    <div class="input-group-append pr-2">
                        <button class="btn btn-outline-light" type="submit" id="button-addon1">
                            <i class="ti-search"></i>
                        </button>
                    </div>
                    <a style="align-content: right" href="/session/getall" class="btn nav-link bg-danger-bright" title="返回全部" data-toggle="tooltip">
                        <i data-feather="log-out"></i>
                    </a>
                </div>
            </form>

        </div>
        <!-- begin::chat sidebar search -->

        <!-- end::chat list -->
        <div class="chat-sidebar-content">
            <div class="tab-content pt-3 p-b-150">
                <div class="tab-pane fade show active innerbox" role="tabpanel" aria-labelledby="pills-home-tab">
                    <div class="chat-lists">
                        <div class="list-group scroll-pane list-group-flush">
                            <a th:each="l, rowInfo:${sessionlist}"  th:href="@{/session-message/get/(id=${l.sessionid})}"
                               class="list-group-item d-flex align-items-center link-1 pl-0 pr-1 pb-3 pt-3">
                                <div class="pr-3">
                                    <div class="avatar avatar-sm avatar-state-danger">
                                        <div class="avatar avatar-sm avatar-state-success">
                                            <img th:src="@{'assets/media/image/photo'+ ${rowInfo.count} +'.jpg'}"
                                                 class="rounded-circle"
                                                 alt="img">
                                        </div>
                                    </div>
                                </div>
                                <div>
                                    <h6 class="mb-1"><div th:text="${l.name}"></div></h6>
                                    <span class="small text-muted"><div th:text="${l.content}"></div></span>
                                </div>
                                <div class="text-right ml-auto">
                                    <span class="badge badge-primary badge-pill ml-auto"></span>
                                    <span class="small text-muted"><div th:text="${l.date}"></div></span>
                                </div>
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- end::chat list -->
    </div>
    <!-- end::chat sidebar -->

    <!-- begin::chat content -->
    <div class="col-lg-8 chat-content">

        <!-- begin::chat header -->
        <div class="chat-header border-bottom">
            <div class="d-flex align-items-center">
                <div class="pr-3">
                    <div class="avatar avatar-sm ">
                        <img src="assets/media/image/photo1.jpg" class="rounded-circle" >
                    </div>
                </div>
                <div>
                    <h6 class="mb-1">[[${session.name}]]</h6>
                    <div class="m-0 small text-success">
                        <div th:text="${session.active}"></div>
                    </div>
                    <div class="ml-auto">
                    </div>
                    <ul class="nav align-items-center">
                        <li class="mr-4 d-sm-inline d-none">
                            <a href="#" title="Start Video Call" data-toggle="tooltip">
                                <i data-feather="video" class="width-18 height-18"></i>
                            </a>
                        </li>
                        <li class="mr-4 d-sm-inline d-none">
                            <a href="#" title="Start Voice Call" data-toggle="tooltip">
                                <i data-feather="phone-call" class="width-18 height-18"></i>
                            </a>
                        </li>
                        <li class="d-sm-inline d-none">
                            <a href="#" title="Add to Contact" data-toggle="tooltip">
                                <i data-feather="user-plus" class="width-18 height-18"></i>
                            </a>
                        </li>
                        <li class="ml-4 mobile-chat-close-btn">
                            <a href="#" class="btn btn-sm btn-danger">
                                <i data-feather="x" class="width-18 height-18"></i>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <!-- end::chat header -->

        <!-- begin::messages -->
        <div class="messages innerbox">

            <tr th:each="c, State : ${session.content}">
                <div shiro:hasPermission="announce" class=""th:class="${c.fromvisitor} ? 'message-item ' : 'message-item me' ">

                    <div class="message-item-content" >[[${c.content}]]</div>
                    <span class="time small text-muted font-italic">[[${c.time}]]</span>

                </div>
                <div shiro:lacksPermission="announce" class=""th:class="${c.fromvisitor} ? 'message-item me' : 'message-item ' ">

                    <div class="message-item-content" >[[${c.content}]]</div>
                    <span class="time small text-muted font-italic">[[${c.time}]]</span>

                </div>
            </tr>
        </div>
        <!-- end::messages -->

        <!-- begin::chat footer -->
        <div class="chat-footer border-top">
            <form class="d-flex" action="/session-message/submit">
                <button class="btn btn-outline-light mr-2" type="button" title="Emoji"
                        data-toggle="tooltip">
                    <i data-feather="smile" class="width-15 height-15"></i>
                </button>
                <div class="flex-grow-1">
                    <input type="text" name="content" class="form-control" placeholder="Write your message">
                </div>
                <div class="chat-footer-buttons d-flex">
                    <button class="btn btn-primary" type="submit">
                        <i data-feather="send" class="width-15 height-15"></i>
                    </button>
                </div>
            </form>
        </div>
        <!-- end::chat footer -->

    </div>
    <!-- begin::chat content -->

</div>
<!-- begin::chat block -->

</body>
</html>